package cn.tedu.wms.passport.service.impl;

import cn.tedu.wms.passport.mapper.AdminMapper;
import cn.tedu.wms.passport.mapper.LoginLogMapper;
import cn.tedu.wms.passport.pojo.dto.LoginLogAddNewDTO;
import cn.tedu.wms.passport.pojo.entity.LoginLog;
import cn.tedu.wms.passport.pojo.vo.LoginLogListItemVO;
import cn.tedu.wms.passport.service.ILoginLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author yhy@tedu.cn
 * @version 0.0.1
 */
@Slf4j
@Service
public class LoginLogServiceImpl implements ILoginLogService {

    @Autowired
    LoginLogMapper loginLogMapper;

    @Autowired
    AdminMapper adminMapper;

    public LoginLogServiceImpl() {
        log.info("创建业务对象：LoginLogServiceImpl");
    }

    @Override
    public void addNew(LoginLogAddNewDTO loginLogAddNewDTO) {
        log.debug("开始执行【新增日志】的业务......");
        LoginLog loginLog = new LoginLog();
        BeanUtils.copyProperties(loginLogAddNewDTO, loginLog);
        loginLogMapper.insert(loginLog);
        log.debug("添加成功！");
    }

    @Override
    public int count() {
        return loginLogMapper.count();
    }

    @Override
    public List<LoginLogListItemVO> list() {
        return loginLogMapper.list();
    }
}
